//
//  YQPersonCenterVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/21.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQPersonCenterVC.h"
#import "YQMeHeadView.h"
#import "YQMetableViewCell.h"
#import "YQManagerWalletVC.h"

@interface YQPersonCenterVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *meTableView;
@property (nonatomic, strong) YQMeHeadView *meView;
@property (nonatomic, strong) NSArray *leftListArr;
@property (nonatomic, strong) NSArray *leftImgArr;

@end

@implementation YQPersonCenterVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.headView setHidden:YES];
//    self.view.backgroundColor = UIColorFromRGB(0xeeeeee);
    self.txtTitle.text = @"我的";
    self.leftListArr = @[@[@"管理钱包",@"交易中心",@"消息中心",@"地址簿"],@[@"精选投票",@"系统设置",@"关于我们",@"帮助中心"]];
    self.leftImgArr = @[@[@"1",@"1",@"1",@"1"],@[@"1",@"1",@"1",@"1"]];
    [self setupMeView];
}

- (void)setupMeView {
    [self.view addSubview:self.meView];
    [self.meView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.mas_equalTo(FIT(60));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-FIT(32), FIT(75)));
    }];
    
    [self.view addSubview:self.meTableView];
    [self.meTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.equalTo(self.meView.mas_bottom).mas_equalTo(FIT(40));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, ScreenHeight-FIT(135)));
    }];
}

- (YQMeHeadView *)meView {
    if (!_meView) {
        _meView = [[YQMeHeadView alloc] init];
    }
    return _meView;
}

- (UITableView *)meTableView {
    if (!_meTableView) {
        _meTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _meTableView.delegate = self;
        _meTableView.dataSource = self;
        _meTableView.tableFooterView = [[UIView alloc] init];
        [_meTableView  setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        [_meTableView registerNib:[UINib nibWithNibName:YQ_MetableViewCell bundle:nil] forCellReuseIdentifier:YQ_MetableViewCell];
    }
    return _meTableView;
}

#pragma mark - 代理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.leftListArr.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.leftListArr[section] count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(60);
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return section == 0?0:FIT(10);
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.001;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQMetableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_MetableViewCell forIndexPath:indexPath];
    cell.theTitleLab.text = self.leftListArr[indexPath.section][indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.section == 0 ) {
        if (indexPath.row == 0) {
            YQ_PUSH([YQManagerWalletVC new]);
        }
    }
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return nil;
}

//- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
//    return nil;
//}

@end
